//
//  CLSettingViewController.m
//  CarLifes
//
//  Created by yu on 2017/6/26.
//  Copyright © 2017年 jpas. All rights reserved.
//

#import "CLSettingViewController.h"
#import "ModifyPsdViewController.h"
#import "MRProgress.h"


@interface CLSettingViewController ()

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@property (nonatomic, strong) MRProgressOverlayView *progressView;

@end

@implementation CLSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"设置";
    
    UIButton *modifyPwBtn = [self buttonWithTitle:@"修改密码" bgColor:[UIColor whiteColor] sel:@selector(modifyPasswordAction)];
    [modifyPwBtn setImage:IMAGE_NAMED(@"arrow_right") forState:UIControlStateNormal];
    
    [self.scrollView addSubview:modifyPwBtn];
    
    modifyPwBtn.sd_layout
    .leftEqualToView(self.scrollView)
    .rightEqualToView(self.scrollView)
    .topSpaceToView(self.scrollView, 10)
    .heightIs(40);
    
    
    modifyPwBtn.titleLabel.sd_layout
    .leftSpaceToView(modifyPwBtn, 10)
    .centerYEqualToView(modifyPwBtn);
    
    modifyPwBtn.imageView.sd_layout
    .rightSpaceToView(modifyPwBtn, 10)
    .centerYEqualToView(modifyPwBtn)
    .widthIs(8)
    .heightIs(14);
    
    UIButton *clearCkBtn = [self buttonWithTitle:@"清除缓存" bgColor:[UIColor whiteColor] sel:@selector(clearCookiesAction)];
    [self.scrollView addSubview:clearCkBtn];
    
    clearCkBtn.sd_layout
    .leftEqualToView(self.scrollView)
    .rightEqualToView(self.scrollView)
    .topSpaceToView(modifyPwBtn, 10)
    .heightIs(40);
    
    clearCkBtn.titleLabel.sd_layout
    .leftSpaceToView(clearCkBtn, 10)
    .centerYEqualToView(clearCkBtn);
    
    [self.scrollView setupAutoContentSizeWithBottomView:clearCkBtn bottomMargin:0];
}

- (void)modifyPasswordAction
{
    ModifyPsdViewController *modifyPassword = [[ModifyPsdViewController alloc] init];
//    modifyPassword.type = @0;
    [self.navigationController pushViewController:modifyPassword animated:YES];
}

- (void)clearCookiesAction
{

}

- (UIButton *)buttonWithTitle:(NSString *)title bgColor:(UIColor *)bgColor sel:(SEL)sel
{
    UIButton *button = [[UIButton alloc] init];
    button.titleLabel.font = SYSTEM_FONT(15);
    [button setTitle:title forState:UIControlStateNormal];
    button.backgroundColor = bgColor;
    [button addTarget:self action:sel forControlEvents:UIControlEventTouchUpInside];
    [button setTitleColor:kTextBlackColor forState:UIControlStateNormal];
    
    return button;
}

- (void)performBlock:(void(^)())block afterDelay:(NSTimeInterval)delay {
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), block);
}


@end
